/*
//====================创建历史====================
//文件名称：calendar.js
//创 建 者：徐晶
//创建时间：2009-09-17
//功能描述：日历控件
//====================修改历史====================
//修改时间：
//修 改 者：
//修改内容：
//================================================

//参数列表
ShowYearBefore
ShowYearAfter

TitleBarClassName

TdDropYearClassName
TdSpanYearClassName
TdSpanYearAddClassName
TdDropMonthClassName
TdSpanMonthClassName
TdSpanMonthAddClassName
TdSpanClearClassName
TdSpanCloseClassName
TdSpanYearMinusClassName
TdSpanMonthMinusClassName

DropYearClassName
YearStr
SpanYearClassName
YearAddStr
SpanYearAddClassName
DropMonthClassName
MonthStr
SpanMonthClassName
MonthAddStr
SpanMonthAddClassName
ClearStr
SpanClearClassName
CloseStr
SpanCloseClassName

YearMinusStr
SpanYearMinusClassName
MonthMinusStr
SpanMonthMinusClassName

CalTblClassName
WeekDayStr
CalTblTitleTdClassName

CalID
ContainerClassName

appendNode
openNode
valueNode
showNode

levelalign
verticalalign

CalTdOtherMonthWeekEndClassName
CalTdOtherMonthClassName
CalTdThisMonthWeekEndClassName
CalTdThisMonthClassName

clickFunc
*/
(function(){
	var Calendar=window.Calendar=function( p_jsnPara ){
		this._arrPrivate['arrCalConfig']=p_jsnPara instanceof Object?p_jsnPara:{};
		p_jsnPara=null;
		this._arrPrivate['intCalSelectedYear']=this._arrPrivate['intCalThisYear']=new Date().getFullYear();
		this._arrPrivate['intCalSelectedMonth']=this._arrPrivate['intCalThisMonth']=new Date().getMonth()+1;
		this._arrPrivate['intCalSelectedDay']=this._arrPrivate['intCalThisDay']=new Date().getDate();
		this._arrPrivate['arrDaysInMonth']=[31,28,31,30,31,30,31,31,30,31,30,31];
		/* 0代表周日，1代表周一 */
		this._arrPrivate['intStartDay']=0;
		this._arrPrivate['intMinYear']=this._arrPrivate['intCalThisYear']-(this._arrPrivate['arrCalConfig'].ShowYearBefore?this._arrPrivate['arrCalConfig'].ShowYearBefore:70);
		this._arrPrivate['intMaxYear']=this._arrPrivate['intCalThisYear']+(this._arrPrivate['arrCalConfig'].ShowYearAfter?this._arrPrivate['arrCalConfig'].ShowYearAfter:30);
		if(this._arrPrivate['arrCalConfig'].valueNode?this._arrPrivate['arrCalConfig'].valueNode.value:''){
			var a=this.str2a(this._arrPrivate['arrCalConfig'].valueNode.value,'-');
			var o=this.str2o(a[0],a[1],a[2]);
			if(o){
				if(a[0]>=this._arrPrivate['intMinYear']&&a[0]<=this._arrPrivate['intMaxYear']){
					this._arrPrivate['intCalSelectedYear']=o.getFullYear();
					this._arrPrivate['intCalSelectedMonth']=o.getMonth()+1;
					this._arrPrivate['intCalSelectedDay']=o.getDate();
				}
			}
		}

		/* 日历头部开始 */
		var TitleBar=document.createElement('table');
		TitleBar.className=this._arrPrivate['arrCalConfig'].TitleBarClassName?this._arrPrivate['arrCalConfig'].TitleBarClassName:'titlebar';
		var TitleBartr1=TitleBar.insertRow(0);
		var TitleBartr2=TitleBar.insertRow(1);

		var TdDropYear=TitleBartr1.insertCell(0);
		TdDropYear.className=this._arrPrivate['arrCalConfig'].TdDropYearClassName?this._arrPrivate['arrCalConfig'].TdDropYearClassName:'tddropyear';
		var TdSpanYear=TitleBartr1.insertCell(1);
		TdSpanYear.className=this._arrPrivate['arrCalConfig'].TdSpanYearClassName?this._arrPrivate['arrCalConfig'].TdSpanYearClassName:'tdspanyear';
		TdSpanYearAdd=TitleBartr1.insertCell(2);
		TdSpanYearAdd.className=this._arrPrivate['arrCalConfig'].TdSpanYearAddClassName?this._arrPrivate['arrCalConfig'].TdSpanYearAddClassName:'tdspanyearadd';
		var TdDropMonth=TitleBartr1.insertCell(3);
		TdDropMonth.className=this._arrPrivate['arrCalConfig'].TdDropMonthClassName?this._arrPrivate['arrCalConfig'].TdDropMonthClassName:'tddropmonth';
		var TdSpanMonth=TitleBartr1.insertCell(4);
		TdSpanMonth.className=this._arrPrivate['arrCalConfig'].TdSpanMonthClassName?this._arrPrivate['arrCalConfig'].TdSpanMonthClassName:'tdspanmonth';
		TdSpanMonthAdd=TitleBartr1.insertCell(5);
		TdSpanMonthAdd.className=this._arrPrivate['arrCalConfig'].TdSpanMonthAddClassName?this._arrPrivate['arrCalConfig'].TdSpanMonthAddClassName:'tdspanmonthadd';
		var TdSpanClear=TitleBartr1.insertCell(6);
		TdSpanClear.className=this._arrPrivate['arrCalConfig'].TdSpanClearClassName?this._arrPrivate['arrCalConfig'].TdSpanClearClassName:'tdspanclear';
		var TdSpanClose=TitleBartr1.insertCell(7);
		TdSpanClose.className=this._arrPrivate['arrCalConfig'].TdSpanCloseClassName?this._arrPrivate['arrCalConfig'].TdSpanCloseClassName:'tdspanclose';

		TdSpanYearMinus=TitleBartr2.insertCell(0);
		TdSpanYearMinus.className=this._arrPrivate['arrCalConfig'].TdSpanYearMinusClassName?this._arrPrivate['arrCalConfig'].TdSpanYearMinusClassName:'tdspanyearminus';
		TdSpanMonthMinus=TitleBartr2.insertCell(1);
		TdSpanMonthMinus.className=this._arrPrivate['arrCalConfig'].TdSpanMonthMinusClassName?this._arrPrivate['arrCalConfig'].TdSpanMonthMinusClassName:'tdspanmonthminus';

		this._arrPrivate['dropYear']=document.createElement('select');
		this._arrPrivate['dropYear'].className=this._arrPrivate['arrCalConfig'].DropYearClassName?this._arrPrivate['arrCalConfig'].DropYearClassName:'dropyear';
		for( var i=this._arrPrivate['intMinYear'];i<this._arrPrivate['intMaxYear'];++i){
			this._arrPrivate['dropYear'].options.add(new Option(i,i),0);
		}
		this.synDropYear();
		TdDropYear.rowSpan=2;
		TdDropYear.appendChild(this._arrPrivate['dropYear']);

		var SpanYear=document.createElement('span');
		SpanYear.innerHTML=this._arrPrivate['arrCalConfig'].YearStr?this._arrPrivate['arrCalConfig'].YearStr:'年';
		SpanYear.className=this._arrPrivate['arrCalConfig'].SpanYearClassName?this._arrPrivate['arrCalConfig'].SpanYearClassName:'spanyear';
		TdSpanYear.rowSpan=2;
		TdSpanYear.appendChild(SpanYear);

		SpanYearAdd=document.createElement('span');
		SpanYearAdd.innerHTML=this._arrPrivate['arrCalConfig'].YearAddStr?this._arrPrivate['arrCalConfig'].YearAddStr:'+';
		SpanYearAdd.className=this._arrPrivate['arrCalConfig'].SpanYearAddClassName?this._arrPrivate['arrCalConfig'].SpanYearAddClassName:'spanyearadd';
		TdSpanYearAdd.appendChild(SpanYearAdd);

		this._arrPrivate['dropMonth']=document.createElement('select');
		this._arrPrivate['dropMonth'].className=this._arrPrivate['arrCalConfig'].DropMonthClassName?this._arrPrivate['arrCalConfig'].DropMonthClassName:'dropmonth';
		for( var i=1;i<13;++i){
			this._arrPrivate['dropMonth'].options.add(new Option(this.appendZero(i),i),0);
		}
		this.synDropMonth(this);
		TdDropMonth.rowSpan=2;
		TdDropMonth.appendChild(this._arrPrivate['dropMonth']);

		var SpanMonth=document.createElement('span');
		SpanMonth.innerHTML=this._arrPrivate['arrCalConfig'].MonthStr?this._arrPrivate['arrCalConfig'].MonthStr:'月';
		SpanMonth.className=this._arrPrivate['arrCalConfig'].SpanMonthClassName?this._arrPrivate['arrCalConfig'].SpanMonthClassName:'spanmonth';
		TdSpanMonth.rowSpan=2;
		TdSpanMonth.appendChild(SpanMonth);

		SpanMonthAdd=document.createElement('span');
		SpanMonthAdd.innerHTML=this._arrPrivate['arrCalConfig'].MonthAddStr?this._arrPrivate['arrCalConfig'].MonthAddStr:'+';
		SpanMonthAdd.className=this._arrPrivate['arrCalConfig'].SpanMonthAddClassName?this._arrPrivate['arrCalConfig'].SpanMonthAddClassName:'spanmonthadd';
		TdSpanMonthAdd.appendChild(SpanMonthAdd);

		var SpanClear=document.createElement('span');
		SpanClear.innerHTML=this._arrPrivate['arrCalConfig'].ClearStr?this._arrPrivate['arrCalConfig'].ClearStr:'清除';
		SpanClear.className=this._arrPrivate['arrCalConfig'].SpanClearClassName?this._arrPrivate['arrCalConfig'].SpanClearClassName:'spanclear';
		TdSpanClear.rowSpan=2;
		TdSpanClear.appendChild(SpanClear);

		var SpanClose=document.createElement('span');
		SpanClose.innerHTML=this._arrPrivate['arrCalConfig'].CloseStr?this._arrPrivate['arrCalConfig'].CloseStr:'关闭';
		SpanClose.className=this._arrPrivate['arrCalConfig'].SpanCloseClassName?this._arrPrivate['arrCalConfig'].SpanCloseClassName:'spanclose';
		TdSpanClose.rowSpan=2;
		TdSpanClose.appendChild(SpanClose);

		SpanYearMinus=document.createElement('span');
		SpanYearMinus.innerHTML=this._arrPrivate['arrCalConfig'].YearMinusStr?this._arrPrivate['arrCalConfig'].YearMinusStr:'-';
		SpanYearMinus.className=this._arrPrivate['arrCalConfig'].SpanYearMinusClassName?this._arrPrivate['arrCalConfig'].SpanYearMinusClassName:'spanyearminus';
		TdSpanYearMinus.appendChild(SpanYearMinus);

		SpanMonthMinus=document.createElement('span');
		SpanMonthMinus.innerHTML=this._arrPrivate['arrCalConfig'].MonthMinusStr?this._arrPrivate['arrCalConfig'].MonthMinusStr:'-';
		SpanMonthMinus.className=this._arrPrivate['arrCalConfig'].SpanMonthMinusClassName?this._arrPrivate['arrCalConfig'].SpanMonthMinusClassName:'spanmonthminus';
		TdSpanMonthMinus.appendChild(SpanMonthMinus);

		/* 日历头部结束 */
		/* 日历部分开始 */
		var CalTbl=document.createElement('table');
		CalTbl.className=this._arrPrivate['arrCalConfig'].CalTblClassName?this._arrPrivate['arrCalConfig'].CalTblClassName:'caltbl';
		CalTblTitle=CalTbl.insertRow(0);
		CalTblTitleTd=[];
		var defaultWeekDayStr=[
				'日','一','二','三','四','五','六'
		];
		/* 根据每周开始日画出星期几 */
		this._arrPrivate['arrCalConfig'].CalTblTitleTdClassName=this._arrPrivate['arrCalConfig'].CalTblTitleTdClassName?this._arrPrivate['arrCalConfig'].CalTblTitleTdClassName:'caltbltitletd';
		this._arrPrivate['arrCalConfig'].WeekDayStr=this._arrPrivate['arrCalConfig'].WeekDayStr?this._arrPrivate['arrCalConfig'].WeekDayStr:defaultWeekDayStr;
		for( var i=0;i<7;++i){
			CalTblTitleTd.push(CalTblTitle.insertCell(i));
			CalTblTitleTd[i].innerHTML=this._arrPrivate['arrCalConfig'].WeekDayStr[i+this._arrPrivate['intStartDay']>=defaultWeekDayStr.length?i-defaultWeekDayStr.length+this._arrPrivate['intStartDay']:	i+this._arrPrivate['intStartDay']];
			CalTblTitleTd[i].className=this._arrPrivate['arrCalConfig'].CalTblTitleTdClassName;
		}
		this._arrPrivate['arrCalTr']=[];
		this._arrPrivate['arrCalTd']=[];
		for( var i=1;i<7;++i){
			this._arrPrivate['arrCalTr'].push(CalTbl.insertRow(i));
			for( var j=0;j<7;++j){
				this._arrPrivate['arrCalTd'].push(this._arrPrivate['arrCalTr'][i-1].insertCell(j));
			}
		}
		/* 日历部分结束 */
		/* 日历显示开始 */
		this._arrPrivate['divCalContainer']=document.createElement('div');
		this._arrPrivate['arrCalConfig'].CalID?this._arrPrivate['divCalContainer'].id=this._arrPrivate['arrCalConfig'].CalID:'';
		this._arrPrivate['divCalContainer'].className=this._arrPrivate['arrCalConfig'].ContainerClassName?this._arrPrivate['arrCalConfig'].ContainerClassName:'container';
		this.appendEle(this._arrPrivate['divCalContainer'],TitleBar);
		this.appendEle(this._arrPrivate['divCalContainer'],CalTbl);
		this.appendEle(this._arrPrivate['arrCalConfig'].appendNode?this._arrPrivate['arrCalConfig'].appendNode:document.body,this._arrPrivate['divCalContainer']);
		this.drawCal();
		/* 日历显示结束 */
		/* 追加事件开始 */
		this.bindEvent(SpanYearAdd,'click',this.getFunc(this,this.nextYear));
		this.bindEvent(SpanYearMinus,'click',this.getFunc(this,this.preYear));
		this.bindEvent(SpanMonthAdd,'click',this.getFunc(this,this.nextMonth));
		this.bindEvent(SpanMonthMinus,'click',this.getFunc(this,this.preMonth));
		this.bindEvent(this._arrPrivate['dropYear'],'change',this.getFunc(this,this.dropYear));
		this.bindEvent(this._arrPrivate['dropMonth'],'change',this.getFunc(this,this.dropMonth));
		this.bindEvent(SpanClose,'click',this.getFunc(this,this.hide));
		this._arrPrivate['arrCalConfig'].openNode?this.bindEvent(this._arrPrivate['arrCalConfig'].openNode,'click',this.getFunc(this,this.show)):'';
		this._arrPrivate['arrCalConfig'].valueNode?this.bindEvent(SpanClear,'click',this.getFunc(this,this.clear)):'';
		/* 追加事件结束 */
	}.extend( Base ),
	pt = Calendar.prototype;
	//显示
	pt.show=function(){
		this.setProps(this._arrPrivate['divCalContainer'],{
			style:{
				display:'block'
			}
		});
		this._arrPrivate['arrCalConfig'].showNode=this._arrPrivate['arrCalConfig'].showNode?this._arrPrivate['arrCalConfig'].showNode:this._arrPrivate['arrCalConfig'].openNode;
		var pos=this.getPos(this._arrPrivate['arrCalConfig'].showNode),l=pos.left,t=pos.top+this._arrPrivate['arrCalConfig'].showNode.offsetHeight;
		if(this._arrPrivate['arrCalConfig'].levelalign){
			switch(this._arrPrivate['arrCalConfig'].levelalign){
				case 'left':
					l=pos.left;
					break;
				case 'right':
					l=pos.left+this._arrPrivate['arrCalConfig'].showNode.offsetWidth-this._arrPrivate['divCalContainer'].offsetWidth;
					break;
				case 'center':
					l=pos.left+(this._arrPrivate['arrCalConfig'].showNode.offsetWidth-this._arrPrivate['divCalContainer'].offsetWidth)/2;
					break;
			}
		}
		if(this._arrPrivate['arrCalConfig'].verticalalign){
			switch(this._arrPrivate['arrCalConfig'].verticalalign){
				case 'top':
					t=pos.top-this._arrPrivate['divCalContainer'].offsetHeight;
					break;
				case 'bottom':
					t=pos.top+this._arrPrivate['arrCalConfig'].showNode.offsetHeight;
				case 'middle':
					t=pos.top+(this._arrPrivate['arrCalConfig'].showNode.offsetHeight-this._arrPrivate['divCalContainer'].offsetHeight)/2;
					break;
			}
		}
		this.setPosX(this._arrPrivate['divCalContainer'],l);
		this.setPosY(this._arrPrivate['divCalContainer'],t);
		if(!this._arrPrivate['divCalContainer'].resizefunc){
			this.bindEvent(window,'resize',this._arrPrivate['divCalContainer'].resizefunc=this.getFunc(this,this.show));
		}
	};
	//关闭
	pt.hide=function(){
		if(this._arrPrivate['divCalContainer'].resizefunc){
			this.removeEvent(window,'resize',this._arrPrivate['divCalContainer'].resizefunc);
		}
		this.setProps(this._arrPrivate['divCalContainer'],{
			style:{
				display:'none'
			}
		});
	};	
	//清除
	pt.clear=function(){
		this._arrPrivate['arrCalConfig'].valueNode.value='';
	};
	//补零
	pt.appendZero=function(n){
		return(('00'+n).substr(('00'+n).length-2));
	};
	//字符串转换为对象
	pt.str2o=function(y,m,d){
		try{
			return new Date(y,parseInt(m,10)-1,parseInt(d,10));
		}catch(e){
			return new Date();
		}
	};
	//对象拆分
	pt.o2a=function(o){
		var s=[];
		s['y']=o.getFullYear();
		s['m']=o.getMonth()+1;
		s['d']=o.getDate();
		return s;
	};
	//字符串拆分
	pt.str2a=function(s,c){
		return s.split(c?c:'-');
	};
	//对象转换数组
	pt.o2str=function(o,t){
		var s=[];
		s['y']=o.getFullYear();
		s['m']=o.getMonth()+1;
		s['d']=o.getDate();
		if(0==t){
			return s['y']+'-'+this.appendZero(s['m'])+'-'+this.appendZero(s['d']);
		}else{
			return s['y']+'-'+s['m']+'-'+s['d'];
		}
	};
	//是否周末
	pt.isWeekEnd=function(o){
		return 6==o.getDay()||0==o.getDay();
	};
	//画日历部分
	pt.drawCal=function(){
		this._arrPrivate['arrDaysInMonth'][1]=(0==this._arrPrivate['intCalSelectedYear']%4&&(this._arrPrivate['intCalSelectedYear']%100!=0||this._arrPrivate['intCalSelectedYear']%400==0))?29:28;
		/* 本月第一天是星期几 */
		var w=this.str2o(this._arrPrivate['intCalSelectedYear'],this._arrPrivate['intCalSelectedMonth'],1).getDay();
		/* 上个月有几天 */
		prevDays=this._arrPrivate['intCalSelectedMonth']==1?this._arrPrivate['arrDaysInMonth'][11]:this._arrPrivate['arrDaysInMonth'][this._arrPrivate['intCalSelectedMonth']-2];
		/* 日期对象 */
		this._arrPrivate['arrDays']=[];
		/* 根据this._arrPrivate['intStartDay']校正偏差 */
		w=w-this._arrPrivate['intStartDay']<0?w+7-this._arrPrivate['intStartDay']:w-this._arrPrivate['intStartDay'];
		var CalTdOtherMonthWeekEndClassName=this._arrPrivate['arrCalConfig'].CalTdOtherMonthWeekEndClassName?this._arrPrivate['arrCalConfig'].CalTdOtherMonthWeekEndClassName:'caltdothermonthweekend';
		var CalTdOtherMonthClassName=this._arrPrivate['arrCalConfig'].CalTdOtherMonthClassName?this._arrPrivate['arrCalConfig'].CalTdOtherMonthClassName:'caltblothermonth';
		for( var i=w-1;i>-1;--i){
			/* 填充去年12月的最后几天到日历 */
			if(this._arrPrivate['intCalSelectedMonth']==1){
				this._arrPrivate['arrDays'][i]=this.str2o(this._arrPrivate['intCalSelectedYear']-1,12,prevDays);
			}else{
				/* 填充上一个月的最后几天到日历 */
				this._arrPrivate['arrDays'][i]=this.str2o(this._arrPrivate['intCalSelectedYear'],this._arrPrivate['intCalSelectedMonth']-1,prevDays);
			}
			prevDays--;
			if(this.isWeekEnd(this._arrPrivate['arrDays'][i])){
				this._arrPrivate['arrCalTd'][i].className=CalTdOtherMonthWeekEndClassName;
			}else{
				this._arrPrivate['arrCalTd'][i].className=CalTdOtherMonthClassName;
			}
		}
		/* 填充本月的日历 */
		var CalTdThisMonthWeekEndClassName=this._arrPrivate['arrCalConfig'].CalTdThisMonthWeekEndClassName?this._arrPrivate['arrCalConfig'].CalTdThisMonthWeekEndClassName:'caltdthismonthweekend';
		var CalTdThisMonthClassName=this._arrPrivate['arrCalConfig'].CalTdThisMonthClassName?this._arrPrivate['arrCalConfig'].CalTdThisMonthClassName:'caltdthismonth';
		for( var i=1;i<=this._arrPrivate['arrDaysInMonth'][this._arrPrivate['intCalSelectedMonth']-1];++i){
			this._arrPrivate['arrDays'][i+w-1]=this.str2o(this._arrPrivate['intCalSelectedYear'],this._arrPrivate['intCalSelectedMonth'],i);
			if(this.isWeekEnd(this._arrPrivate['arrDays'][i+w-1])){
				this._arrPrivate['arrCalTd'][i+w-1].className=CalTdThisMonthWeekEndClassName;
			}else{
				this._arrPrivate['arrCalTd'][i+w-1].className=CalTdThisMonthClassName;
			}
		}
		var CalTdOtherMonthWeekEndClassName=this._arrPrivate['arrCalConfig'].CalTdOtherMonthWeekEndClassName?this._arrPrivate['arrCalConfig'].CalTdOtherMonthWeekEndClassName:'caltdothermonthweekend';
		var CalTdOtherMonthClassName=this._arrPrivate['arrCalConfig'].CalTdOtherMonthClassName?this._arrPrivate['arrCalConfig'].CalTdOtherMonthClassName:'caltblothermonth';
		for( var i=1;i<42-(w-1)-this._arrPrivate['arrDaysInMonth'][this._arrPrivate['intCalSelectedMonth']-1];++i){
			/* 填充明年1月的前几天到日历 */
			if(this._arrPrivate['intCalSelectedMonth']==12){
				this._arrPrivate['arrDays'][this._arrPrivate['arrDaysInMonth'][this._arrPrivate['intCalSelectedMonth']-1]+w-1+i]=this.str2o(this._arrPrivate['intCalSelectedYear']+1,1,i);
			}else{
				/* 填充下一个月的前几天到日历 */
				this._arrPrivate['arrDays'][this._arrPrivate['arrDaysInMonth'][this._arrPrivate['intCalSelectedMonth']-1]+w-1+i]=this.str2o(this._arrPrivate['intCalSelectedYear'],this._arrPrivate['intCalSelectedMonth']+1,i);
			}
			if(this.isWeekEnd(this._arrPrivate['arrDays'][this._arrPrivate['arrDaysInMonth'][this._arrPrivate['intCalSelectedMonth']-1]+w-1+i])){
				this._arrPrivate['arrCalTd'][this._arrPrivate['arrDaysInMonth'][this._arrPrivate['intCalSelectedMonth']-1]+w-1+i].className=CalTdOtherMonthWeekEndClassName;
			}else{
				this._arrPrivate['arrCalTd'][this._arrPrivate['arrDaysInMonth'][this._arrPrivate['intCalSelectedMonth']-1]+w-1+i].className=CalTdOtherMonthClassName;
			}
		}
		/* 这个循环是根据源数组写到日历里显示 */
		this._arrPrivate['arrCalConfig'].clickFunc=this._arrPrivate['arrCalConfig'].clickFunc?this._arrPrivate['arrCalConfig'].clickFunc:	function( day ){ this._arrPrivate['arrCalConfig'].valueNode.value = day; };
		for( var i=0;i<42;++i){
			var a=this.o2a(this._arrPrivate['arrDays'][i]);
			this._arrPrivate['arrCalTd'][i].innerHTML=this.appendZero(a['d']);
			this._arrPrivate['arrCalTd'][i].title=this.o2str(this._arrPrivate['arrDays'][i],0);
			this._arrPrivate['arrCalTd'][i].onclick?this.removeEvent(this._arrPrivate['arrCalTd'][i],'click',this._arrPrivate['arrCalTd'][i].onclick):'';
			this.bindEvent(this._arrPrivate['arrCalTd'][i],'click',this._arrPrivate['arrCalTd'][i].onclick=this.getFunc(this,this._arrPrivate['arrCalConfig'].clickFunc,this.o2str(this._arrPrivate['arrDays'][i],0)));
			this.bindEvent(this._arrPrivate['arrCalTd'][i],'click',this.getFunc(this,this.hide));
		}
	};
	//同步下拉年
	pt.synDropYear=function(){
		for( var i=0;i<this._arrPrivate['dropYear'].options.length;++i){
			if(this._arrPrivate['dropYear'].options[i].value==this._arrPrivate['intCalSelectedYear']){
				this._arrPrivate['dropYear'].options[i].selected=true;
				break;
			}
		}
	};
	//同步下拉月
	pt.synDropMonth=function(){
		for( var i=0;i<this._arrPrivate['dropMonth'].options.length;++i){
			if(this._arrPrivate['dropMonth'].options[i].value==this._arrPrivate['intCalSelectedMonth']){
				this._arrPrivate['dropMonth'].options[i].selected=true;
				break;
			}
		}
	};
	//下拉选择年
	pt.dropYear=function(){
		this._arrPrivate['intCalSelectedYear']=parseInt(this._arrPrivate['dropYear'].options[this._arrPrivate['dropYear'].selectedIndex].value,10);
		this.drawCal();
	};
	//下拉选择月
	pt.dropMonth=function(){
		this._arrPrivate['intCalSelectedMonth']=parseInt(this._arrPrivate['dropMonth'].options[this._arrPrivate['dropMonth'].selectedIndex].value,10);
		this.drawCal();
	};
	//下一年
	pt.nextYear=function(){
		if(this._arrPrivate['intCalSelectedYear']==this._arrPrivate['intMaxYear']){
			return;
		}else{
			++this._arrPrivate['intCalSelectedYear'];
		}
		this.synDropYear();
		this.drawCal();
	};
	//下一个月
	pt.nextMonth=function(){
		if(12==this._arrPrivate['intCalSelectedMonth']){
			++this._arrPrivate['intCalSelectedYear'];
			this._arrPrivate['intCalSelectedMonth']=1;
		}else{
			++this._arrPrivate['intCalSelectedMonth'];
		}
		this.synDropYear();
		this.synDropMonth();
		this.drawCal();
	};
	//上一年
	pt.preYear=function(){
		if(this._arrPrivate['intCalSelectedYear']==this._arrPrivate['intMinYear']){
			return;
		}else{
			--this._arrPrivate['intCalSelectedYear'];
		}
		this.synDropYear();
		this.drawCal();
	};
	//上一个月
	pt.preMonth=function(){
		if(1==this._arrPrivate['intCalSelectedMonth']){
			--this._arrPrivate['intCalSelectedYear'];
			this._arrPrivate['intCalSelectedMonth']=12;
		}else{
			--this._arrPrivate['intCalSelectedMonth'];
		}
		this.synDropYear();
		this.synDropMonth();
		this.drawCal();
	};
})();